using UnityEngine;
using System.Collections;

public class ActionController : MonoBehaviour {

    public const string START_BUTTON = "START";
    public const string RESTART_BUTTON = "RESTART";
    public const string HIT_BUTTON = "HIT";
    public const string STOP_BUTTON = "STOP";

    public UIButton StartButton;
    private Vector3 startButtonPos;
    public UIButton RestartButton;
    public UIButton HitButton;
    private Vector3 hitButtonPos;
    public UIButton StopButton;
    private Vector3 stopButtonPos;

    public UILabel TipLabel;
    private Transform tipLabelTransform;

    private Vector3 hideButtonPos;

    private GameObject[] chairs;

    void Awake()
    {
        chairs = GameObject.FindGameObjectsWithTag("Chair");
    }


	// Use this for initialization
	void Start () {
        startButtonPos = StartButton.transform.position;
        hitButtonPos = HitButton.transform.position;
        stopButtonPos = StopButton.transform.position;

        hideButtonPos = new Vector3(-1000,-1000,0);

        HideButton(START_BUTTON);
        HideButton(HIT_BUTTON);
        HideButton(STOP_BUTTON);
	}


    void OnStartButtonClick() {
        Debug.Log("Start");
    }

    void OnRestartButtonClick()
    {
        BlackJackController.Restart();
    }

    void OnStopButtonClick()
    {
        Debug.Log("Stop");
    }

    void OnHitButtonClick()
    {
        Debug.Log("Hit");
    }

    public void HideButton(string name)
    {
        switch (name)
        {
            case ActionController.START_BUTTON:
                StartButton.transform.position = hideButtonPos;
                break;
            case ActionController.STOP_BUTTON:
                StopButton.transform.position = hideButtonPos;
                break;
            case ActionController.HIT_BUTTON:
                HitButton.transform.position = hideButtonPos;
                break;
        }
    }
    public void ShowButton(string name)
    {
        switch (name)
        {
            case ActionController.START_BUTTON:
                StartButton.transform.position = startButtonPos;
                break;
            case ActionController.STOP_BUTTON:
                StopButton.transform.position = stopButtonPos;
                break;
            case ActionController.HIT_BUTTON:
                HitButton.transform.position = hitButtonPos;
                break;
        }
    }
    public void TipText(string text)
    {
        TipLabel.text = text;
    }

    public void EnabledChair(int seat,bool enabled)
    {
        for (int i = 0; i < chairs.Length; i++)
        {
            ChairSprite chairSprite = chairs[i].GetComponent<ChairSprite>();

            if (seat == chairSprite.Seat)
            {
                chairSprite.enabled = enabled;
            }
        }
    }
}
